<?php
echo '<pre>';
//echo is_uploaded_file($_FILES['userfile']['tmp_name']); //1 true 有文件上
//is_uploaded_file() 判断有没有上传文件

$uploaddir = 'upload/user/';
if (!file_exists($uploaddir)) mkdir($uploaddir, 777, true);

if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
    //print_r($_FILES);
    $fn = $_FILES['userfile']['name'];
    $array = explode('.', $fn);
    //$fnn = uniqid() . '.' . array_pop($array);
    $fnn = date('YmdHis') . '_' . mt_rand(1000, 9999) . '.' . array_pop($array);
    move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $fnn);
}
//move_uploaded_file() 移动上传文件
?>
<img src="<?= $uploaddir . $fnn ?>" alt="">
